package servlet;


import dom.logdom;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/loServlet")
public class loServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        logdom lo = new logdom();
        lo.setUserid(request.getParameter("id"));
        lo.setPassword(request.getParameter("mm"));
        try {
            String name = lo.login(lo.getUserid(), lo.getPassword());
            if (name != null) {
                boolean flag1 = lo.login2(name);
                if (flag1) {
                    response.sendRedirect("administrator.jsp");
                } else {
                    response.sendRedirect("./html/home.html");
                }
            } else {
                response.sendRedirect("index.jsp");
            }
        } catch (SQLException | ClassNotFoundException e) {

        }

    }
}



